13. Testing the Room Database

L6 23 Test The Room Database SC

Now it's your turn to run the test yourself.

In this step, you'll try out code for testing your Room database.

  1. Use the solution code from the previous exercise, which you can download here: Step.03-Solution-Create-RoomDatabase. Work from that code, or copy the test file to your code.

  2. In the androidTest folder, open the SleepDatabaseTest file.

  3. Uncomment the code.

  4. Right-click on the test file in the Project view and choose Run.

  5. After the app builds and runs, verify in the SleepDatabaseTest pane that all the tests have passed.

Bonus Exercise: Add tests to exercise the other DAO methods. There is no solution code provided for this optional challenge. You can use the Testing Training in the Android Developer Documentation to dive deeper.

Task Description:

Complete these tasks to test your Room database.

Task List:

Task Feedback:

Do you feel reassured?

Reference documentation